/**
 * Description:一些注释<br/>
 * CreateTime:2019-04-16<br/>
 * Creater: yangpengfei@think.cn <br/>
 */
layui.use(['jquery','element','layer'],function(){
	const $ = layui.jquery;
	const element = layui.element;
	const layer = layui.layer;
	let errorMessage = "json格式化服务异常，请稍后重试！";
	
	$(document).on('click','#formatBtn',function(){
		$.ajax({
			url:"/toolInfo/jsonFormat",
			type:"POST",
			data:{
				jsonSource:$("#jsonSourceInfo").val()
			},
			dataType:"text",
			success:function(data){
				$("#jsonFormatResultBox").empty();
				$("#jsonFormatResultBox").append("<textarea class='layui-textarea' name='jsonFormatResult' wrap='virtual' style='min-height:300px;' id='jsonFormatResult' readonly='readonly'> " +data + "</textarea>");
			},
			error:function(){
				layer.msg(errorMessage);
				$("#jsonFormatResultBox").empty();
				$("#jsonFormatResultBox").append("<textarea class='layui-textarea' name='jsonFormatResult' wrap='virtual' style='min-height:300px;' id='jsonFormatResult' readonly='readonly'> " +errorMessage + "</textarea>");
			}
		});
	});
	//清空内容
	$(document).on('click','#clearContent',function(){
		$("#jsonSourceInfo").val("");
		$("#jsonSourceInfo").text("");
	});
});